#include <stdio.h>
#include <stdlib.h>
#include <windows.h> 
void PrintAll(int x, int y, int width, int height) 
{ 
    for (int k=0;k<width; k++) printf("█");
    printf("\n");
	for (int i=1; i<height-1;i++) 
	{  
		printf("█");
		for (int j=1; j<width-1; j++) 
		{
			if (i==y&&j==x) printf("Ο"); 
			else printf("  ");	
		}
		printf("█\n"); 
	}
	for (k=0;k<width;k++) printf("█");
	printf("\n\n");
}
int main() 
{
	int x, y, speed_x, speed_y;
	x = 1, y = 1;
	speed_x=speed_y=1;
	
	int left, down, top, right;
	left = top = 0, down = 20, right = 40;
	
	while (1) 
	{	
		PrintAll(x,y,right,down); 
		y+=speed_y; 
		x+=speed_x;
		if (y+2==down||y-1==top) 
		{ 
			speed_y = -speed_y;
			printf("\a"); 
        } 
		if (x+2==right||x-1==left) 
		{ 
			speed_x=-speed_x;
			printf("\a");	
        }  
        
		Sleep(50);
		system("cls");
	}	
	return 0;
} 
